import axios from 'axios';
// import store from '../store/index'
export function request(config){
  const instance = axios.create({
    baseURL: window.CONFIG.baseUrl,
    timeout: 40000
  })
  // 请求拦截
  instance.interceptors.request.use(config => {
    // config.headers.Authorization = store.state.token
    // if(config.url.indexOf('yun_power')!=-1){
    //   config.headers.Authorization = "yun_power yOobGuOcjgKS6cuq";
    // }
    // if(config.url.indexOf('addAreaSet')!=-1){
    //   config.headers['Content-Type'] = "multipart/form-data"
    // }
    return config
  }, err => {
    console.log(err)
  })
  // 响应拦截
  instance.interceptors.response.use(res => {
    return res
  }, err => {
    console.log(err)
  })
  
  // instance.interceptors.request.use(config => {
  //   console.log(config)
  // }, success = (res) =>{
  //   console.log(res, 'rsuccess')
  //   return
  // }, failure = (err) =>{
  //   console.log(err, 'failure')
  // })
  return instance(config)
}